import java.util.HashSet;
import java.util.Scanner;

public class Ex {
	public static void main(String[] args) {
		Function f = null;
		HashSet<Integer> answer;
		Scanner sc = new Scanner(System.in);
		System.out.println("Hey there, and welcome to my exercise!");
		int quit = 2;
		int a = 1;
		String x = null;
		while (quit != 0) {
			System.out.println("Please enter size of group.");
			int n = sc.nextInt();
			System.out.println("Please enter tau.");
			double tau = sc.nextDouble();
			System.out.println("Please enter delta.");
			double delta = sc.nextDouble();
			System.out.println("Please enter ||f|| infinity.");
			double norm = sc.nextDouble();
			if (quit == 2) {
				System.out.println("Enter 0 for using the XML. Enter any other int for not using XML");
				a = sc.nextInt();
				if (a==0) {
					System.out.println("Please enter XML file name");
					x = sc.next();
				}
			}
				if (a==0) {
				f = new XMLFunction(x, n, norm);
			}
			else {
				f = new userFunction(norm);
			}
			System.out.println("Computing...");
			answer = Algorithem.SFT(n, tau, delta, f);
			System.out.println("The heavy coefficients are:");
			for (int t : answer) {
				System.out.println(t);
			}
			answer = null;
			System.out.println("If you want to quit, enter 0.");
			System.out.println("If you want to do another run with the same function, enter 1.");
			System.out.println("If you want to do another run with a different function, enter 2.");
			System.out.println("If you want to do the same run, enter 3.");
			quit = sc.nextInt();
			while (quit == 3) {
				System.out.println("Computing...");
				answer = Algorithem.SFT(n, tau, delta, f);
				System.out.println("The heavy coefficients are:");
				for (int t : answer) {
					System.out.println(t);
				}
				answer = null;
				System.out.println("If you want to quit, enter 0.");
				System.out.println("If you want to do another run with the same function, enter 1.");
				System.out.println("If you want to do another run with a different function, enter 2.");
				System.out.println("If you want to do the same run, enter 3.");
				quit = sc.nextInt();
			}
		}
	}
}